package 常用类.Array类.比较器;

import java.util.Arrays;

public class UserTest {
    public static void main(String[] args) {
        User[] users=new User[3];
        users[0]=new User(10,"Hello",20,180);
        users[1]=new User(2,"Welcome",27,176);
        users[2]=new User(7,"jiazhong",28,185);

        System.out.println("根据ID升序排序");
        Arrays.sort(users);
        System.out.println(Arrays.toString(users));

        System.out.println("根据ID降序排序");
        Arrays.sort(users,new User.SortIdDesc());
        System.out.println(Arrays.toString(users));

        System.out.println("根据年龄升序排序");
        Arrays.sort(users,new User.SortAgeAsc());
        System.out.println(Arrays.toString(users));

        System.out.println("根据年龄降序排序");
        Arrays.sort(users,new User.SortAgeDesc());
        System.out.println(Arrays.toString(users));
    }
}
